<template>
    <div>
        <el-card class='box-card'>
            <el-form :model='numberValidateForm' ref='numberValidateForm' label-width='100px' class='demo-ruleForm'>
                <el-form-item
                    label='设备名称'
                    :rules="[
      { required: true, message: '配件名称不能为空'}
    ]"
                >
                    <el-input type='text' v-model='numberValidateForm.name' autocomplete='off'></el-input>
                </el-form-item>
                <el-form-item
                    label='编号'
                >
                    <el-input type='text' v-model='numberValidateForm.account' autocomplete='off'></el-input>
                </el-form-item>
                <el-form-item
                    label='类型'
                >
                    <el-input type='text' v-model='numberValidateForm.type' autocomplete='off'></el-input>
                </el-form-item>
                <el-form-item
                    label='使用时间'
                >
                    <el-input type='text' v-model='numberValidateForm.playDept' autocomplete='off'></el-input>
                </el-form-item>
                <el-form-item
                    label='出厂时间'
                >
                    <el-input type='text' v-model='numberValidateForm.chuT' autocomplete='off'></el-input>
                </el-form-item>
                <el-form-item
                    label='保修时间'
                >
                    <el-input type='number' v-model='numberValidateForm.baoT' autocomplete='off'></el-input>
                </el-form-item>
                <el-form-item
                    label='密级'
                >
                    <el-input type='text' v-model='numberValidateForm.mi' autocomplete='off'></el-input>
                </el-form-item>
                <el-form-item
                    label='备注'
                >
                    <el-input type='text' v-model='numberValidateForm.demo' autocomplete='off'></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type='primary' @click="save(numberValidateForm)">提交</el-button>
                    <el-button @click="reset">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>

    </div>
</template>

<script>
export default {
    data() {
        return {
            numberValidateForm: {
                account:'',
                type:'',
                name:'',
                playDept:'',
                chuT:'',
                baoT:null,
                mi:'',
                demo:''
            }
        }
    },
    methods: {
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    alert('submit!')
                } else {
                    console.log('error submit!!')
                    return false
                }
            })
        },
        resetForm(formName) {
            this.$refs[formName].resetFields()
        },
        save(data){
            this.$http.post("/v1/unit/save",data).then(res => {
                this.$notify({
                    title: '添加成功',
                    type: 'success'
                });
                this.numberValidateForm={}
            })
        },
        reset(){
            this.numberValidateForm = {}
        }
    }
}
</script>

<style scoped>

</style>
